package ru.niir.goodfil.ui;

import ru.niir.goodfil.db.Order;

import javax.faces.context.FacesContext;
import java.util.Map;


public class MainOrderInfoBean extends PageBean {

    private Order mainOrder;

    public MainOrderInfoBean() {
        init();
    }

    public void init(){
        long mainOrderId = 0;
        Map sessionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
        StorekeeperOrdersBean reportBean = (StorekeeperOrdersBean)sessionMap.get("StorekeeperOrdersBean");
        if(reportBean != null){
            mainOrderId = reportBean.getMainOrderId();
            mainOrder = gf().getOrderById(mainOrderId);
            mainOrder.setClient(gf().getClientById(mainOrder.getClientId()));
            mainOrder.setManager(gf().getUserById(mainOrder.getManagerId()));
            gf().addOrderInfo(mainOrder);
        }
    }

    public Order getMainOrder() {
        return mainOrder;
    }

    public void setMainOrder(Order mainOrder) {
        this.mainOrder = mainOrder;
    }
}
